package zirao.base.widget;

import android.content.Context;
import android.support.v4.widget.NestedScrollView;
import android.util.AttributeSet;

/**
 * Created by ${lixiaonan} on 2017/12/26.
 */
public class MyNestedScrollView extends NestedScrollView{

    public interface ScrollViewListener{
        void onScrollChanged(MyNestedScrollView scrollview, int x, int y, int oldx, int oldy);
    }

    private ScrollViewListener  scrollViewListener = null;

    public MyNestedScrollView(Context context) {
        super(context);
    }

    public MyNestedScrollView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public MyNestedScrollView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    public void setScrollViewListener(ScrollViewListener scrollViewListener){
        this.scrollViewListener = scrollViewListener;
    }

    @Override
    protected void onScrollChanged(int l, int t, int oldl, int oldt) {
        super.onScrollChanged(l, t, oldl, oldt);
        if(scrollViewListener != null){
            scrollViewListener.onScrollChanged(this,l, t, oldl, oldt);
        }
    }
}